﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Ruction.Mapping2
{
    /// <summary>Represents a playable game map.</summary>
    public class Map : BaseObjectCollection<Region>
    {
        #region Properties

        #region Countries
        /// <summary>Gets a list of all countries in the map.</summary>
        public List<Land> Countries { get { return GetRegionsOf<Land>(); } }
        #endregion Countries

        #region Waters
        /// <summary>Gets a list of all waters in the map.</summary>
        public List<Water> Waters { get { return GetRegionsOf<Water>(); } }
        #endregion Waters

        #endregion Properties

        #region Methods

        #region GetRegionsOf
        /// <summary>Gets all regions of a particular type from this instance.</summary>
        /// <typeparam name="T">The type of region to get.</typeparam>
        /// <returns>A list of the regions of type <typeparamref name="T" />.</returns>
        private List<T> GetRegionsOf<T>() where T : Region
        {
            return (from r in this
                    where r.GetType().Equals(typeof(T))
                    select r as T).ToList();
        }
        #endregion GetRegionsOf

        #endregion Methods
    }
}